<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Title</title>
    <link rel="stylesheet" href="static/bootstrap/dist/css/bootstrap.min.css">
    <script src="static/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
</head>

<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light position-fixed top-0 w-100">
    <div class="container">
        <a class="navbar-brand" href="#">智能系统</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
                aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="/index.html">首页</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="/users.html">用户信息</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="/articles.html">意见箱</a>
                </li>
            </ul>
            <form class="d-flex">
                <input class="form-control me-2" type="search" placeholder="搜索内容" aria-label="Search">
                <button class="btn btn-outline-success" type="submit">Search</button>
            </form>

            <ul class="navbar-nav ms-auto">
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
                       data-bs-toggle="dropdown" aria-expanded="false">
                        账户
                    </a>
                    <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <li><a class="dropdown-item" href="/login.html">登录</a></li>
                        <li><a class="dropdown-item" href="#">退出</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>
<br><br><br>

<div class="container">
    <div class="row">
        <div class="col">
            <div class="d-flex justify-content-between align-items-center mb-3">
                <h1>意见展</h1>
                <button type="button" class="btn btn-primary" data-bs-toggle="modal"
                        data-bs-target="#staticBackdrop">
                    发表意见
                </button>
            </div>
            <hr>
            <div id="feedbackList">
                <div class="card mb-2">
                    <div class="card-body">
                        <h5 class="card-title">标题: 超时连接</h5>
                        <p class="card-text">当请求资源过大或者网络信号不好时，会出现连接超时的情况，从而出现错误</p>
                        <a href="#" class="btn btn-primary">了解详情</a>
                    </div>
                </div>
                <div class="card mb-2">
                    <div class="card-body">
                        <h5 class="card-title">标题: 网络访问不稳定</h5>
                        <p class="card-text">当请求资源过大或者网络信号不好时，会出现连接超时的情况，从而出现错误</p>
                        <a href="#" class="btn btn-primary">了解详情</a>
                    </div>
                </div>
                <div class="card mb-2">
                    <div class="card-body">
                        <h5 class="card-title">标题: 无法搜到验证码</h5>
                        <p class="card-text">当请求资源过大或者网络信号不好时，会出现连接超时的情况，从而出现错误</p>
                        <a href="#" class="btn btn-primary">了解详情</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Modal -->
<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1"
     aria-labelledby="staticBackdropLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content bg-light">
            <div class="modal-header">
                <h5 class="modal-title" id="staticBackdropLabel">意见框</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <div class="mb-3">
                    <label for="exampleFormControlTitle" class="form-label">问题</label>
                    <input type="text" class="form-control" id="exampleFormControlTitle"
                           placeholder="请问你对哪一个方面有什么意见：">
                </div>
                <div class="mb-3">
                    <label for="exampleFormControlTextarea1" class="form-label">需求</label>
                    <textarea class="form-control" id="exampleFormControlTextarea1" rows="3" placeholder="请详细说明你有什么需求："></textarea>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="submitFeedback">发表</button>
            </div>
        </div>
    </div>
</div>

<script>
    document.getElementById('submitFeedback').addEventListener('click', function () {
        // 获取用户输入的标题和需求
        const title = document.getElementById('exampleFormControlTitle').value;
        const content = document.getElementById('exampleFormControlTextarea1').value;

        // 检查用户是否输入了标题和内容
        if (title.trim() === '' || content.trim() === '') {
            alert('请填写标题和需求！');
            return;
        }

        // 创建新的卡片
        const feedbackList = document.getElementById('feedbackList');
        const newCard = document.createElement('div');
        newCard.className = 'card mb-2';

        newCard.innerHTML = `
                <div class="card-body">
                    <h5 class="card-title">标题: ${title}</h5>
                    <p class="card-text">${content}</p>
                    <a href="#" class="btn btn-primary">了解详情</a>
                </div>
            `;

        // 将新的卡片添加到列表中
        feedbackList.prepend(newCard);

        // 关闭模态框并清空输入字段
        const modal = bootstrap.Modal.getInstance(document.getElementById('staticBackdrop'));
        modal.hide();

        // 清空输入字段
        document.getElementById('exampleFormControlTitle').value = '';
        document.getElementById('exampleFormControlTextarea1').value = '';
    });
</script>

</body>

</html>